//懒汉模式创建单例
class SingletonLazy {
    private static volatile SingletonLazy instance  = null;
    private static Object locker = new Object();

    public static SingletonLazy getInstance() {
        if(instance == null) {
            synchronized (locker) {
                if (instance == null) {
                    instance = new SingletonLazy();
                }
            }
        }
        return instance;
    }

    private SingletonLazy() {}

}
public class Test {
    public static void main(String[] args) {
        SingletonLazy t1 = SingletonLazy.getInstance();
        SingletonLazy t2 = SingletonLazy.getInstance();
        System.out.println(t1 == t2);

    }

}
